package dang.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

public class LoggedInInterceptor extends MethodFilterInterceptor{

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		Map<String, Object> session= invocation.getInvocationContext().getSession();
		String resultCode = "";
		if(session.get("user") != null){
			resultCode = invocation.invoke();
		}else{
			resultCode = "notLoggedIn";
			session.put("error", "未登录，请先登录");
		}
		return resultCode;
	}

}
